<%@ page language="java"
	import="com.byxy.model.FlowInfo, com.byxy.util.DateUtil, java.util.List"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>显示所有党员外出流动信息</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link href="Styles/bootstrap.min.css" rel="stylesheet" type="text/css">

<script type="text/javascript">
	function CheckAll(elementsA, elementsB) {
		for (i = 0; i < elementsA.length; i++) {
			elementsA[i].checked = true;
		}
		if (elementsB.checked == false) {
			for (j = 0; j < elementsA.length; j++) {
				elementsA[j].checked = false;
			}
		}
	}
	//判断用户是否选择了要删除的记录，如果是，则提示“是否删除”；否则提示“请选择要删除的记录”
	function checkdel(delid, formname) {
		var flag = false;
		for (i = 0; i < delid.length; i++) {
			if (delid[i].checked) {
				flag = true;
				break;
			}
		}
		if (!flag) {
			alert("请选择要删除的记录！");
			return false;
		} else {
			if (confirm("确定要删除吗？")) {
				formname.submit();
			}
		}
	}
	function chkads() {
		if (if_selectid.txtid.value == "") {
			alert("编号不能为空.");
			if_selectid.txtid.select();
			return false;
		}
		if (!IsNum(if_selectid.txtid.value)) {
			alert("请输入数字!")
			if_selectid.txtid.focus();
			return false;
		}
	}
	function IsNum(num) {
		var reNum = /^\d*$/;
		return (reNum.test(num));
	}
</script>

</head>

<body>
	<%
		if (session.getAttribute("loginResult") == null) {
			response.sendRedirect("./login.html");
		}
	%>
	<form onSubmit="return chkads()" name="if_selectid"
		action="./FlowInfoFindByIdServlet" method="get">

		<table class="table table-striped table-bordered table-condensed list">
			<tbody>
				<tr>
					<td>输入查询的编号：</td>
					<td><input type="text" name="txtid" /></td>&nbsp;&nbsp;&nbsp;&nbsp;
					<td><input class="btn btn-inverse" id="find" type="submit"
						value="查询" />
						</form>
						<input type="button" class="btn btn-inverse"
						onclick="javascript:window.location.href='FlowInfo/input.html';"
						value="添加" /></td>
				</tr>
			</tbody>
		</table>

		<form action="./FlowInfoDelServlet" method="post" name="frm">
			<table
				class="table table-striped table-bordered table-condensed list">
				<tr>
					<td>编号</td>
					<td>姓名</td>
					<td>性别</td>

					<td>出生年月</td>
					<td>党龄</td>
					<td>学历</td>
					<td>曾任党内职务</td>

					<td>是否持有流动党员证</td>

					<td>联系电话</td>

					<td>部门编号</td>
					<td>&nbsp;删除</td>
					<td align="center">操作</td>
				</tr>
				<%
					List<FlowInfo> list = (List<FlowInfo>) request.getAttribute("result");
					if (list == null || list.size() < 1) {
						out.print("<tr><td bgcolor='#FFFFFF' colspan='6'>没有任何信息！</td></tr>");
					} else {
						for (FlowInfo flow : list) {
				%>
				<tr class="demo">
					<td><%=flow.getId()%></td>
					<td><%=flow.getName()%></td>
					<td><%=flow.getSex()%></td>

					<td><%=DateUtil.utilDateTosqlDate(flow.getBirthday())%></td>
					<td><%=flow.getPartyStanding()%></td>
					<td><%=flow.getEducation()%></td>
					<td><%=flow.getPosted()%></td>

					<td>
						<%
							if (flow.isMobilePartyCard() == true) {
										out.print("是");
									} else {
										out.print("否");
									}
						%>
					</td>

					<td><%=flow.getContactNumber()%></td>
					<td><%=flow.getDepartmentId()%></td>
					<td><input name="delid" type="checkbox" class="noborder"
						value="<%=flow.getId()%>"></td>
					<td>
						<div class="button-group">
							<a class="button border-main"
								href="FlowInfo/update.jsp?id=<%=flow.getId()%>"><span
								class="icon-edit"></span>修改</a> <a class="button border-main"
								href="FlowInfo/detailed.jsp?id=<%=flow.getId()%>"><span
								class="icon-edit"></span>详细信息</a>
						</div>
					</td>
				</tr>
				<%
					}
					}
				%>
			</table>
			<footer> <input name="checkbox" type="checkbox"
				class="noborder" onClick="CheckAll(frm.delid,frm.checkbox)">
			[全选/反选] [ <a style="color:red;cursor:pointer;"
				onClick="checkdel(frm.delid,frm)">删除</a>] <a href="#" type=”button”
				name=”submit” onclick="javascript:history.back(-1);">返回上一页</a>
			<div id="ch" style="display: none">
				<input name="delid" type="checkbox" value="0">
			</div>
			<!--层ch用于放置隐藏的checkbox控件，因为当表单中只是一个checkbox控件时，应用javascript获得其length属性值为undefine-->
			</footer>
		</form>
</body>
</html>
